const express = require('express')
      bodyParser = require('body-parser')
      fs = require('fs')
      cookieParser = require('cookie-parser')
      app = express()
      template = require('./template')
      uploads = require('./multer')

      db = require('./db')
      User = db.User
      Ask = db.Ask
      Answer = db.Answer
      
app.use(express.static('www'))
app.use(bodyParser.urlencoded({extended:true}))
app.use(cookieParser())

app.engine('.html',template.__express)
app.set('view engine','html')

const public = require('./public')
      send = public.send
      allQuestions = public.allQuestions
      saveFile = public.saveFile
      signIn = public.signIn
      existQuestion = public.existQuestion

//首页
// 先找静态资源文件夹下的
// 然后处理请求响应
// 各个页面渲染
app.use(require('./routes/index'))
app.use(require('./routes/login'))
app.use(require('./routes/register'))
app.use(require('./routes/user'))
app.use(require('./routes/answer'))
app.use(require('./routes/ask'))
app.use(require('./routes/listaa'))

app.listen(2000,() => {
  console.log('running....')
})
